package com.powernode.teatraceability.raw;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.fisco.bcos.sdk.abi.FunctionReturnDecoder;
import org.fisco.bcos.sdk.abi.TypeReference;
import org.fisco.bcos.sdk.abi.datatypes.Address;
import org.fisco.bcos.sdk.abi.datatypes.Bool;
import org.fisco.bcos.sdk.abi.datatypes.Event;
import org.fisco.bcos.sdk.abi.datatypes.Function;
import org.fisco.bcos.sdk.abi.datatypes.Type;
import org.fisco.bcos.sdk.abi.datatypes.Utf8String;
import org.fisco.bcos.sdk.abi.datatypes.generated.Uint256;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple2;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple5;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple6;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple7;
import org.fisco.bcos.sdk.client.Client;
import org.fisco.bcos.sdk.contract.Contract;
import org.fisco.bcos.sdk.crypto.CryptoSuite;
import org.fisco.bcos.sdk.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.eventsub.EventCallback;
import org.fisco.bcos.sdk.model.CryptoType;
import org.fisco.bcos.sdk.model.TransactionReceipt;
import org.fisco.bcos.sdk.model.callback.TransactionCallback;
import org.fisco.bcos.sdk.transaction.model.exception.ContractException;

@SuppressWarnings("unchecked")
public class Enterprise extends Contract {
    public static final String[] BINARY_ARRAY = {"608060405234801561001057600080fd5b50611c6b806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80632387e2111461005c57806388badeee146103065780639d172e9d14610556578063f9d4cc4f146107a6578063fdff96ac14610a46575b600080fd5b610304600480360360c081101561007257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001906401000000008111156100b957600080fd5b8201836020820111156100cb57600080fd5b803590602001918460018302840111640100000000831117156100ed57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561015057600080fd5b82018360208201111561016257600080fd5b8035906020019184600183028401116401000000008311171561018457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156101e757600080fd5b8201836020820111156101f957600080fd5b8035906020019184600183028401116401000000008311171561021b57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561027e57600080fd5b82018360208201111561029057600080fd5b803590602001918460018302840111640100000000831117156102b257600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050610a94565b005b6103526004803603604081101561031c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e34565b604051808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001806020018060200180602001806020018781526020018615151515815260200185810385528b818151815260200191508051906020019080838360005b838110156103e05780820151818401526020810190506103c5565b50505050905090810190601f16801561040d5780820380516001836020036101000a031916815260200191505b5085810384528a818151815260200191508051906020019080838360005b8381101561044657808201518184015260208101905061042b565b50505050905090810190601f1680156104735780820380516001836020036101000a031916815260200191505b50858103835289818151815260200191508051906020019080838360005b838110156104ac578082015181840152602081019050610491565b50505050905090810190601f1680156104d95780820380516001836020036101000a031916815260200191505b50858103825288818151815260200191508051906020019080838360005b838110156105125780820151818401526020810190506104f7565b50505050905090810190601f16801561053f5780820380516001836020036101000a031916815260200191505b509b50505050505050505050505060405180910390f35b6105a26004803603604081101561056c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061111d565b604051808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001806020018060200180602001806020018781526020018615151515815260200185810385528b818151815260200191508051906020019080838360005b83811015610630578082015181840152602081019050610615565b50505050905090810190601f16801561065d5780820380516001836020036101000a031916815260200191505b5085810384528a818151815260200191508051906020019080838360005b8381101561069657808201518184015260208101905061067b565b50505050905090810190601f1680156106c35780820380516001836020036101000a031916815260200191505b50858103835289818151815260200191508051906020019080838360005b838110156106fc5780820151818401526020810190506106e1565b50505050905090810190601f1680156107295780820380516001836020036101000a031916815260200191505b50858103825288818151815260200191508051906020019080838360005b83811015610762578082015181840152602081019050610747565b50505050905090810190601f16801561078f5780820380516001836020036101000a031916815260200191505b509b50505050505050505050505060405180910390f35b610a44600480360360a08110156107bc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001906401000000008111156107f957600080fd5b82018360208201111561080b57600080fd5b8035906020019184600183028401116401000000008311171561082d57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561089057600080fd5b8201836020820111156108a257600080fd5b803590602001918460018302840111640100000000831117156108c457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561092757600080fd5b82018360208201111561093957600080fd5b8035906020019184600183028401116401000000008311171561095b57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290803590602001906401000000008111156109be57600080fd5b8201836020820111156109d057600080fd5b803590602001918460018302840111640100000000831117156109f257600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611602565b005b610a9260048036036040811015610a5c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611873565b005b6000851015610b0b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f7468697320696e64657820697320696e76616c6964210000000000000000000081525060200191505060405180910390fd5b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490508510610bc1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f456e746572707269736520646f6573206e6f742065786973740000000000000081525060200191505060405180910390fd5b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208581548110610c0a57fe5b906000526020600020906007020160060160009054906101000a900460ff1615610c9c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f456e746572707269736520616c726561647920636f6e6669726d65640000000081525060200191505060405180910390fd5b60008060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208681548110610ce757fe5b9060005260206000209060070201905084816001019080519060200190610d0f929190611b3b565b5083816002019080519060200190610d28929190611b3b565b5082816003019080519060200190610d41929190611b3b565b5081816004019080519060200190610d5a929190611b3b565b507fff021fa95b3ba2822222929c3ba3d0b613bbe1b60e302fdb80ddd35fc47067d38786604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610df0578082015181840152602081019050610dd5565b50505050905090810190601f168015610e1d5780820380516001836020036101000a031916815260200191505b50935050505060405180910390a150505050505050565b60006020528160005260406000208181548110610e4d57fe5b9060005260206000209060070201600091509150508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690806001018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f205780601f10610ef557610100808354040283529160200191610f20565b820191906000526020600020905b815481529060010190602001808311610f0357829003601f168201915b505050505090806002018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610fbe5780601f10610f9357610100808354040283529160200191610fbe565b820191906000526020600020905b815481529060010190602001808311610fa157829003601f168201915b505050505090806003018054600181600116156101000203166002900480601f01","602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561105c5780601f106110315761010080835404028352916020019161105c565b820191906000526020600020905b81548152906001019060200180831161103f57829003601f168201915b505050505090806004018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110fa5780601f106110cf576101008083540402835291602001916110fa565b820191906000526020600020905b8154815290600101906020018083116110dd57829003601f168201915b5050505050908060050154908060060160009054906101000a900460ff16905087565b6000606080606080600080600088101561119f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f7468697320696e64657820697320696e76616c6964210000000000000000000081525060200191505060405180910390fd5b6000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490508810611255576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f456e746572707269736520646f6573206e6f742065786973740000000000000081525060200191505060405180910390fd5b61125d611bbb565b6000808b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002089815481106112a657fe5b90600052602060002090600702016040518060e00160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600182018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113ae5780601f10611383576101008083540402835291602001916113ae565b820191906000526020600020905b81548152906001019060200180831161139157829003601f168201915b50505050508152602001600282018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114505780601f1061142557610100808354040283529160200191611450565b820191906000526020600020905b81548152906001019060200180831161143357829003601f168201915b50505050508152602001600382018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114f25780601f106114c7576101008083540402835291602001916114f2565b820191906000526020600020905b8154815290600101906020018083116114d557829003601f168201915b50505050508152602001600482018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156115945780601f1061156957610100808354040283529160200191611594565b820191906000526020600020905b81548152906001019060200180831161157757829003601f168201915b50505050508152602001600582015481526020016006820160009054906101000a900460ff1615151515815250509050806000015181602001518260400151836060015184608001518560a001518660c0015197509750975097509750975097505092959891949750929550565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060e001604052808773ffffffffffffffffffffffffffffffffffffffff16815260200186815260200185815260200184815260200183815260200142815260200160001515815250908060018154018082558091505060019003906000526020600020906007020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001019080519060200190611718929190611b3b565b506040820151816002019080519060200190611735929190611b3b565b506060820151816003019080519060200190611752929190611b3b565b50608082015181600401908051906020019061176f929190611b3b565b5060a0820151816005015560c08201518160060160006101000a81548160ff02191690831515021790555050507f1b81147fc202758b54209103360969659672175168f4179d4a4831ad347f4be78585604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611831578082015181840152602081019050611816565b50505050905090810190601f16801561185e5780820380516001836020036101000a031916815260200191505b50935050505060405180910390a15050505050565b60008110156118ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f7468697320696e64657820697320696e76616c6964210000000000000000000081525060200191505060405180910390fd5b6000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905081106119a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f456e746572707269736520646f6573206e6f742065786973740000000000000081525060200191505060405180910390fd5b6000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081815481106119e957fe5b906000526020600020906007020160060160009054906101000a900460ff1615611a7b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f456e746572707269736520616c726561647920636f6e6669726d65640000000081525060200191505060405180910390fd5b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110611ac657fe5b9060005260206000209060070201905060018160060160006101000a81548160ff0219169083151502179055508273ffffffffffffffffffffffffffffffffffffffff167f3c7783932d0cb5e9182cd2a3e3fc294eb4150459a4ae426322f08a01e9b465c660405160405180910390a2505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10611b7c57805160ff1916838001178555611baa565b82800160010185558215611baa579182015b82811115611ba9578251825591602001919060010190611b8e565b5b509050611bb79190611c10565b5090565b6040518060e00160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160608152602001606081526020016060815260200160608152602001600081526020016000151581525090565b611c3291905b80821115611c2e576000816000905550600101611c16565b5090565b9056fea2646970667358221220e3804c7f23579631e97400baa438d5579637a960a7ddd8bc94acac2d3a831fd264736f6c634300060a0033"};

    public static final String BINARY = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", BINARY_ARRAY);

    public static final String[] SM_BINARY_ARRAY = {};

    public static final String SM_BINARY = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", SM_BINARY_ARRAY);

    public static final String[] ABI_ARRAY = {"[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"EnterpriseAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"name\":\"EnterpriseCertificateApplied\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"EnterpriseAddress\",\"type\":\"address\"}],\"name\":\"EnterpriseCertificateApproved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"EnterpriseAddr\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"name\":\"EnterpriseCertificateChanged\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"EnterpriseCertificates\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"EnterpriseAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"fzr\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"certificateStandard\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"certificateMaterial\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"certificateTime\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"certificateStatus\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_fzr\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_certificateStandard\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_certificateMaterial\",\"type\":\"string\"}],\"name\":\"applyEnterpriseCertificate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"approveEnterpriseCertificate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_fzr\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_certificateStandard\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_certificateMaterial\",\"type\":\"string\"}],\"name\":\"changeEnterpriseCertificate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_address\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_index\",\"type\":\"uint256\"}],\"name\":\"getEnterpriseCertificate\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"EnterpriseAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"fzr\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"certificateStandard\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"certificateMaterial\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"certificateTime\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"certificateStatus\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]"};

    public static final String ABI = org.fisco.bcos.sdk.utils.StringUtils.joinAll("", ABI_ARRAY);

    public static final String FUNC_ENTERPRISECERTIFICATES = "EnterpriseCertificates";

    public static final String FUNC_APPLYENTERPRISECERTIFICATE = "applyEnterpriseCertificate";

    public static final String FUNC_APPROVEENTERPRISECERTIFICATE = "approveEnterpriseCertificate";

    public static final String FUNC_CHANGEENTERPRISECERTIFICATE = "changeEnterpriseCertificate";

    public static final String FUNC_GETENTERPRISECERTIFICATE = "getEnterpriseCertificate";

    public static final Event ENTERPRISECERTIFICATEAPPLIED_EVENT = new Event("EnterpriseCertificateApplied", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Utf8String>() {}));
    ;

    public static final Event ENTERPRISECERTIFICATEAPPROVED_EVENT = new Event("EnterpriseCertificateApproved", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>(true) {}));
    ;

    public static final Event ENTERPRISECERTIFICATECHANGED_EVENT = new Event("EnterpriseCertificateChanged", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Utf8String>() {}));
    ;

    protected Enterprise(String contractAddress, Client client, CryptoKeyPair credential) {
        super(getBinary(client.getCryptoSuite()), contractAddress, client, credential);
    }

    public static String getBinary(CryptoSuite cryptoSuite) {
        return (cryptoSuite.getCryptoTypeConfig() == CryptoType.ECDSA_TYPE ? BINARY : SM_BINARY);
    }

    public List<EnterpriseCertificateAppliedEventResponse> getEnterpriseCertificateAppliedEvents(TransactionReceipt transactionReceipt) {
        List<EventValuesWithLog> valueList = extractEventParametersWithLog(ENTERPRISECERTIFICATEAPPLIED_EVENT, transactionReceipt);
        ArrayList<EnterpriseCertificateAppliedEventResponse> responses = new ArrayList<EnterpriseCertificateAppliedEventResponse>(valueList.size());
        for (EventValuesWithLog eventValues : valueList) {
            EnterpriseCertificateAppliedEventResponse typedResponse = new EnterpriseCertificateAppliedEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.EnterpriseAddr = (String) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.name = (String) eventValues.getNonIndexedValues().get(1).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public void subscribeEnterpriseCertificateAppliedEvent(String fromBlock, String toBlock, List<String> otherTopics, EventCallback callback) {
        String topic0 = eventEncoder.encode(ENTERPRISECERTIFICATEAPPLIED_EVENT);
        subscribeEvent(ABI,BINARY,topic0,fromBlock,toBlock,otherTopics,callback);
    }

    public void subscribeEnterpriseCertificateAppliedEvent(EventCallback callback) {
        String topic0 = eventEncoder.encode(ENTERPRISECERTIFICATEAPPLIED_EVENT);
        subscribeEvent(ABI,BINARY,topic0,callback);
    }

    public List<EnterpriseCertificateApprovedEventResponse> getEnterpriseCertificateApprovedEvents(TransactionReceipt transactionReceipt) {
        List<EventValuesWithLog> valueList = extractEventParametersWithLog(ENTERPRISECERTIFICATEAPPROVED_EVENT, transactionReceipt);
        ArrayList<EnterpriseCertificateApprovedEventResponse> responses = new ArrayList<EnterpriseCertificateApprovedEventResponse>(valueList.size());
        for (EventValuesWithLog eventValues : valueList) {
            EnterpriseCertificateApprovedEventResponse typedResponse = new EnterpriseCertificateApprovedEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.EnterpriseAddress = (String) eventValues.getIndexedValues().get(0).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public void subscribeEnterpriseCertificateApprovedEvent(String fromBlock, String toBlock, List<String> otherTopics, EventCallback callback) {
        String topic0 = eventEncoder.encode(ENTERPRISECERTIFICATEAPPROVED_EVENT);
        subscribeEvent(ABI,BINARY,topic0,fromBlock,toBlock,otherTopics,callback);
    }

    public void subscribeEnterpriseCertificateApprovedEvent(EventCallback callback) {
        String topic0 = eventEncoder.encode(ENTERPRISECERTIFICATEAPPROVED_EVENT);
        subscribeEvent(ABI,BINARY,topic0,callback);
    }

    public List<EnterpriseCertificateChangedEventResponse> getEnterpriseCertificateChangedEvents(TransactionReceipt transactionReceipt) {
        List<EventValuesWithLog> valueList = extractEventParametersWithLog(ENTERPRISECERTIFICATECHANGED_EVENT, transactionReceipt);
        ArrayList<EnterpriseCertificateChangedEventResponse> responses = new ArrayList<EnterpriseCertificateChangedEventResponse>(valueList.size());
        for (EventValuesWithLog eventValues : valueList) {
            EnterpriseCertificateChangedEventResponse typedResponse = new EnterpriseCertificateChangedEventResponse();
            typedResponse.log = eventValues.getLog();
            typedResponse.EnterpriseAddr = (String) eventValues.getNonIndexedValues().get(0).getValue();
            typedResponse.name = (String) eventValues.getNonIndexedValues().get(1).getValue();
            responses.add(typedResponse);
        }
        return responses;
    }

    public void subscribeEnterpriseCertificateChangedEvent(String fromBlock, String toBlock, List<String> otherTopics, EventCallback callback) {
        String topic0 = eventEncoder.encode(ENTERPRISECERTIFICATECHANGED_EVENT);
        subscribeEvent(ABI,BINARY,topic0,fromBlock,toBlock,otherTopics,callback);
    }

    public void subscribeEnterpriseCertificateChangedEvent(EventCallback callback) {
        String topic0 = eventEncoder.encode(ENTERPRISECERTIFICATECHANGED_EVENT);
        subscribeEvent(ABI,BINARY,topic0,callback);
    }

    public Tuple7<String, String, String, String, String, BigInteger, Boolean> EnterpriseCertificates(String param0, BigInteger param1) throws ContractException {
        final Function function = new Function(FUNC_ENTERPRISECERTIFICATES, 
                Arrays.<Type>asList(new Address(param0),
                new Uint256(param1)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}, new TypeReference<Bool>() {}));
        List<Type> results = executeCallWithMultipleValueReturn(function);
        return new Tuple7<String, String, String, String, String, BigInteger, Boolean>(
                (String) results.get(0).getValue(), 
                (String) results.get(1).getValue(), 
                (String) results.get(2).getValue(), 
                (String) results.get(3).getValue(), 
                (String) results.get(4).getValue(), 
                (BigInteger) results.get(5).getValue(), 
                (Boolean) results.get(6).getValue());
    }

    public TransactionReceipt applyEnterpriseCertificate(String _address, String _name, String _fzr, String _certificateStandard, String _certificateMaterial) {
        final Function function = new Function(
                FUNC_APPLYENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(new Address(_address),
                new Utf8String(_name),
                new Utf8String(_fzr),
                new Utf8String(_certificateStandard),
                new Utf8String(_certificateMaterial)),
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public void applyEnterpriseCertificate(String _address, String _name, String _fzr, String _certificateStandard, String _certificateMaterial, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_APPLYENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(new Address(_address),
                new Utf8String(_name),
                new Utf8String(_fzr),
                new Utf8String(_certificateStandard),
                new Utf8String(_certificateMaterial)),
                Collections.<TypeReference<?>>emptyList());
        asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForApplyEnterpriseCertificate(String _address, String _name, String _fzr, String _certificateStandard, String _certificateMaterial) {
        final Function function = new Function(
                FUNC_APPLYENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(new Address(_address),
                new Utf8String(_name),
                new Utf8String(_fzr),
                new Utf8String(_certificateStandard),
                new Utf8String(_certificateMaterial)),
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple5<String, String, String, String, String> getApplyEnterpriseCertificateInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_APPLYENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple5<String, String, String, String, String>(

                (String) results.get(0).getValue(), 
                (String) results.get(1).getValue(), 
                (String) results.get(2).getValue(), 
                (String) results.get(3).getValue(), 
                (String) results.get(4).getValue()
                );
    }

    public TransactionReceipt approveEnterpriseCertificate(String _address, BigInteger _index) {
        final Function function = new Function(
                FUNC_APPROVEENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(new Address(_address),
                new Uint256(_index)),
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public void approveEnterpriseCertificate(String _address, BigInteger _index, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_APPROVEENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(new Address(_address),
                new Uint256(_index)),
                Collections.<TypeReference<?>>emptyList());
        asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForApproveEnterpriseCertificate(String _address, BigInteger _index) {
        final Function function = new Function(
                FUNC_APPROVEENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(new Address(_address),
                new Uint256(_index)),
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple2<String, BigInteger> getApproveEnterpriseCertificateInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_APPROVEENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Uint256>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple2<String, BigInteger>(

                (String) results.get(0).getValue(), 
                (BigInteger) results.get(1).getValue()
                );
    }

    public TransactionReceipt changeEnterpriseCertificate(String _address, BigInteger _index, String _name, String _fzr, String _certificateStandard, String _certificateMaterial) {
        final Function function = new Function(
                FUNC_CHANGEENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(new Address(_address),
                new Uint256(_index),
                new Utf8String(_name),
                new Utf8String(_fzr),
                new Utf8String(_certificateStandard),
                new Utf8String(_certificateMaterial)),
                Collections.<TypeReference<?>>emptyList());
        return executeTransaction(function);
    }

    public void changeEnterpriseCertificate(String _address, BigInteger _index, String _name, String _fzr, String _certificateStandard, String _certificateMaterial, TransactionCallback callback) {
        final Function function = new Function(
                FUNC_CHANGEENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(new Address(_address),
                new Uint256(_index),
                new Utf8String(_name),
                new Utf8String(_fzr),
                new Utf8String(_certificateStandard),
                new Utf8String(_certificateMaterial)),
                Collections.<TypeReference<?>>emptyList());
        asyncExecuteTransaction(function, callback);
    }

    public String getSignedTransactionForChangeEnterpriseCertificate(String _address, BigInteger _index, String _name, String _fzr, String _certificateStandard, String _certificateMaterial) {
        final Function function = new Function(
                FUNC_CHANGEENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(new Address(_address),
                new Uint256(_index),
                new Utf8String(_name),
                new Utf8String(_fzr),
                new Utf8String(_certificateStandard),
                new Utf8String(_certificateMaterial)),
                Collections.<TypeReference<?>>emptyList());
        return createSignedTransaction(function);
    }

    public Tuple6<String, BigInteger, String, String, String, String> getChangeEnterpriseCertificateInput(TransactionReceipt transactionReceipt) {
        String data = transactionReceipt.getInput().substring(10);
        final Function function = new Function(FUNC_CHANGEENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(), 
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Uint256>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        List<Type> results = FunctionReturnDecoder.decode(data, function.getOutputParameters());
        return new Tuple6<String, BigInteger, String, String, String, String>(

                (String) results.get(0).getValue(), 
                (BigInteger) results.get(1).getValue(), 
                (String) results.get(2).getValue(), 
                (String) results.get(3).getValue(), 
                (String) results.get(4).getValue(), 
                (String) results.get(5).getValue()
                );
    }

    public Tuple7<String, String, String, String, String, BigInteger, Boolean> getEnterpriseCertificate(String _address, BigInteger _index) throws ContractException {
        final Function function = new Function(FUNC_GETENTERPRISECERTIFICATE, 
                Arrays.<Type>asList(new Address(_address),
                new Uint256(_index)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Address>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint256>() {}, new TypeReference<Bool>() {}));
        List<Type> results = executeCallWithMultipleValueReturn(function);
        return new Tuple7<String, String, String, String, String, BigInteger, Boolean>(
                (String) results.get(0).getValue(), 
                (String) results.get(1).getValue(), 
                (String) results.get(2).getValue(), 
                (String) results.get(3).getValue(), 
                (String) results.get(4).getValue(), 
                (BigInteger) results.get(5).getValue(), 
                (Boolean) results.get(6).getValue());
    }

    public static Enterprise load(String contractAddress, Client client, CryptoKeyPair credential) {
        return new Enterprise(contractAddress, client, credential);
    }

    public static Enterprise deploy(Client client, CryptoKeyPair credential) throws ContractException {
        return deploy(Enterprise.class, client, credential, getBinary(client.getCryptoSuite()), "");
    }

    public static class EnterpriseCertificateAppliedEventResponse {
        public TransactionReceipt.Logs log;

        public String EnterpriseAddr;

        public String name;
    }

    public static class EnterpriseCertificateApprovedEventResponse {
        public TransactionReceipt.Logs log;

        public String EnterpriseAddress;
    }

    public static class EnterpriseCertificateChangedEventResponse {
        public TransactionReceipt.Logs log;

        public String EnterpriseAddr;

        public String name;
    }
}
